package com.wx.spring.ioc.parsing;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wx
 * @Description: 解析资源策略
 * @date 2019/1/14 001416:34
 */
public class ParsingResourcesStrategy {
    private static final Map<String,ParsingResources>  ParsingResourcesStrategyMap;

    public static final  String keyXmlBean = "ParsingResourcesXmlBean", keyXmlScanning = "ParsingResourcesXmlScanning";
    static {
        ParsingResourcesStrategyMap = new HashMap<>();
        ParsingResourcesStrategyMap.put(keyXmlBean,new ParsingResourcesXmlBean());
        ParsingResourcesStrategyMap.put(keyXmlScanning,new ParsingResourcesXmlScanning());
    }


    private ParsingResourcesStrategy(){
        throw new RuntimeException("解析资源策略禁止实例化");
    }

    /**
     * @description: 获取解析资源策略
     * @author: wx
     * @date: 2019/1/14 0014
     * @param strategyKey 策略key
     * @return: com.wx.spring.ioc.parsing.ParsingResources
     */
    public static ParsingResources getStrategy(String strategyKey){
        ParsingResources parsingResources = ParsingResourcesStrategyMap.get(strategyKey);
        if (parsingResources == null){
            throw new RuntimeException("解析资源策略不存在");
        }
        return parsingResources;
    }
}
